<?php
class Profile extends Admin_Controller
{
	
	function __construct()
	{
		parent::__construct();
		$this->load->model('user_model','user');
	}
	
	function index()
	{
		$data['rs'] = $this->user->get_row($this->session->userdata('id'));
		$this->template->append_metadata(js_validate());
		$this->template->build('user_profile',$data);
	}
	
	function save()
	{
		if($_POST)
		{
			if(!empty($_POST['password']))
			{
				$_POST['password'] = md5($_POST['password']);
				add_log('แก้ไขประวัติและรหัสผ่าน');
			}
			else
			{
				unset($_POST['password']);
				add_log('แก้ไขประวัติ');
			}
			$this->user->save($_POST);
			set_notify('success', lang('save_data_complete'));
		}
		redirect('user/profile');
	}
	
	
	
}
?>